package tcpConn

import (
    "cli-desktop/proto"
    "cli-desktop/public"
)

/*
*  -*- coding:utf8 -*-
*
*  TCP 通信相关实现
*
*  @Author  : chengms
*  @WebSite : chengms.com
*  @Email   : chengms2012@163.com
*  @TIME    : 2020/8/17 16:20
*  @File    : connTcp.go
 */



func ReceiveSeverMsg() {

    for {
        cmd, err := proto.ConnSvc.Reader.Read()
        if err != nil {

            public.Loggerf.Infof("read message err: %T, %v", err, err)
            // client quit
            if err == proto.CloseTcpErr {
                break
            }
            //break
            continue
        }
        CmdHandler(cmd)

    }
    return
}

func TcpConnectionToSvc() error {
    return proto.ConnSvc.ConnectServer(public.Cfg.GetTcpAddr())
}


